<template>
  <touchMoveMenu>
    <!-- 中心按钮 -->
    <div :class="['button', 'center', btnClass]" @click="handleOpen">
      <div class="btn-center">
        <!-- <div class="btn-left">1111</div> -->
        <div class="btn-center-left">
          <van-icon v-show="!isOpen" name="arrow-left" style="color: #fff" />
          <van-icon v-show="isOpen" name="arrow" style="color: #fff" />
        </div>
        <div class="btn-center-right">快速导航</div>
      </div>
    </div>
  </touchMoveMenu>
</template>

<script>
import touchMoveMenu from './touchMoveMenu.vue' //悬浮窗组件
export default {
  components: {
    touchMoveMenu
  },
  data() {
    return {
      isOpen: null //是否打开
    }
  },
  computed: {
    //中心按钮class
    btnClass() {
      return this.isOpen === true ? 'open' : this.isOpen === false ? 'close' : null
    }
  },
  methods: {
    handleOpen() {
      this.isOpen = !this.isOpen
    }
  }
}
</script>

<style lang="scss" scoped>
.button {
  position: absolute;
  right: 0vw;
  bottom: 20vh;
  height: 40px;
  width: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  overflow: hidden;
  transition: all 0.5s ease;
  font-size: 12px;
  touch-action: none;
  color: #fff;
  opacity: 0.9;
  .btn-center {
    display: flex;
    height: 40px;
    justify-content: space-around;
    border-radius: 45px 0 0 45px;
    background: linear-gradient(135deg, #2c68ff 0%, #2c68ff 100%);
    width: 80px;
    align-items: center;
    .btn-center-left {
      width: 20px;
    }
    .btn-center-right {
      width: 20px;
      line-height: 13px;
      font-size: 10px;
      color: #fff;
      -ms-flex-negative: 0;
      flex-shrink: 0;
    }
    .btn-left {
      width: 100px;
      -webkit-transition: all 0.5s;
      transition: all 0.5s;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      margin: 0;
      z-index: 201;
      -ms-flex-negative: 0;
      flex-shrink: 1;
      height: 100%;
      background: #fff;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-pack: justify;
      -ms-flex-pack: justify;
      justify-content: space-between;
      border-radius: 25px 0 0 25px;
      -webkit-box-shadow: 2px 2px 8px 0px rgba(0, 0, 0, 0.2);
      box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
      padding: 0 80px 0 20px;
    }
  }
  .icon {
    width: 100%;
  }

  /**中心按钮**/
  //   &.center {
  //     &.open {
  //       transform: rotate(315deg);
  //     }

  //     &.close {
  //       transform: rotate(0deg);
  //     }
  //   }

  //   /**顶部按钮**/
  //   &.top {
  //     opacity: 0;

  //     &.open {
  //       top: -100rpx;
  //       left: -120rpx;
  //       transform: rotate(360deg);
  //       opacity: 1;
  //     }

  //     &.close {
  //       top: 0rpx;
  //       left: 0rpx;
  //       transform: rotate(360deg);
  //       opacity: 0;
  //     }
  //   }

  //   /**底部按钮**/
  //   &.bottom {
  //     opacity: 0;

  //     &.open {
  //       top: 100rpx;
  //       left: -120rpx;
  //       transform: rotate(360deg);
  //       opacity: 1;
  //     }

  //     &.close {
  //       top: 0rpx;
  //       left: 0rpx;
  //       transform: rotate(360deg);
  //       opacity: 0;
  //     }
  //   }

  //   /**左边按钮**/
  //   &.left {
  //     opacity: 0;

  //     &.open {
  //       top: 0rpx;
  //       left: -180rpx;
  //       transform: rotate(360deg);
  //       opacity: 1;
  //     }

  //     &.close {
  //       top: 0rpx;
  //       left: 0rpx;
  //       transform: rotate(360deg);
  //       opacity: 0;
  //     }
  //   }
}
</style>
